package modellayer;

import java.util.TreeSet;

/**
 * This is the container-class for <code>Item</code>. Since
 * only one instance is needed, future iterations might
 * implement this class as a singleton.
 * 
 * @author (ucn-1semprojekt-dm78-gruppe1)
 *
 */
public class Items extends FileIt
{

	private TreeSet<Item> itemList;
	
	/**
	 * This constructor initializes the <code>Item</code>-collection
	 * to <code>TreeSet</code>. This way, there can be no copies of
	 * <code>Item</code> in the collection. Furthermore the
	 * collection can be sorted. A search could be done faster this
	 * way.
	 * 
	 * @param fileName the place to save the contents of this
	 * container
	 */
	public Items(String fileName)
	{
		super(fileName);
		// TODO Auto-generated constructor stub
		itemList = new TreeSet<Item>();
		setFileItObject(itemList);
	}

	/**
	 * This method is called from <code>super</code> to
	 * ensure correct type-cast after a <code>super.load()</code>
	 * 
	 * @param loaded to be cast into a TreeSet
	 * @see modellayer.FileIt#updateFileItObject(java.lang.Object)
	 */
	@SuppressWarnings("unchecked")
	@Override
	protected void updateFileItObject(Object loaded)
	{
		// TODO Auto-generated method stub
		itemList = (TreeSet<Item>) loaded;
	}

	/**
	 * One intent is to pass this to a control-view GUI
	 * to do some manipulation by user
	 * @return the itemList
	 */
	public TreeSet<Item> getItemList()
	{
		return itemList;
	}

	/**
	 * One intent is to migrate data from an other system
	 * @param itemList the itemList to set
	 */
	public void setItemList(TreeSet<Item> itemList)
	{
		this.itemList = itemList;
	}
	
	
}
